//
//  DecorateAppointMultiTableViewCell.m
//  customer
//
//  Created by Holothurian on 2018/10/30.
//  Copyright © 2018年 yinlong. All rights reserved.
//

#import "DecorateAppointMultiTableViewCell.h"

@implementation DecorateAppointDefaultTableCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        _nameLabel.font = Font28;
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:_nameLabel];
        AutoWeakSelf
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(weakSelf.contentView).offset(15);
            make.size.mas_equalTo(CGSizeMake(70, 20));
        }];
        
        _detailNameLabel = [[UILabel alloc]init];
        _detailNameLabel.font = Font28;
        _detailNameLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        [self.contentView addSubview:_detailNameLabel];
        [_detailNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView).offset(15);
            make.right.equalTo(weakSelf.contentView).offset(-10);
            make.left.equalTo(weakSelf.nameLabel.mas_right).offset(10);
            make.height.mas_equalTo(20);
        }];
    }
    return self;
}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end


@implementation DecorateAppointTapSelectTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        _nameLabel.font = Font28;
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:_nameLabel];
        AutoWeakSelf
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(weakSelf.contentView).offset(15);
            make.size.mas_equalTo(CGSizeMake(70, 20));
        }];
        
        _selectTypeLabel = [[UILabel alloc]init];
        _selectTypeLabel.font = Font28;
        _selectTypeLabel.text = @"点击选择类型";
        _selectTypeLabel.userInteractionEnabled = YES;
        _selectTypeLabel.textColor = [HSPublic colorWithHexString:@"B2B2B2"];
        [self.contentView addSubview:_selectTypeLabel];
        [_selectTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView).offset(15);
            make.right.equalTo(weakSelf.contentView).offset(-40);
            make.left.equalTo(weakSelf.nameLabel.mas_right).offset(10);
            make.height.mas_equalTo(20);
        }];
        
        _downImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"selectTypeDown"]];
        _downImgView.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:_downImgView];
        [_downImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(weakSelf.contentView).offset(-10);
            make.centerY.equalTo(weakSelf.contentView);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(selectLabelAction)];
        [self.selectTypeLabel addGestureRecognizer:tap];
    }
    return self;
}

- (void)cellForLayout:(NSString *)value{
    if (!([value isEqualToString:@"点击选择类型"] || k_Is_Empty(value))) {
        self.selectTypeLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        self.selectTypeLabel.text = value?:@"";
    }else{
        self.selectTypeLabel.textColor = [HSPublic colorWithHexString:@"B2B2B2"];
        self.selectTypeLabel.text = @"点击选择类型";
    }
}


- (void)selectLabelAction{
    if ([self.delegate respondsToSelector:@selector(tapSelectTableCellEventWithIndexPath:)]) {
        [self.delegate tapSelectTableCellEventWithIndexPath:self.indexPath];
    }
}

@end


@implementation DecorateAppointSquare2TableCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        _nameLabel.font = Font28;
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:_nameLabel];
        AutoWeakSelf
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(weakSelf.contentView).offset(15);
            make.size.mas_equalTo(CGSizeMake(70, 20));
        }];
        
        _squareTextField = [[UITextField alloc]init];
        _squareTextField.font = Font28;
        _squareTextField.textColor = [HSPublic colorWithHexString:@"333333"];
        _squareTextField.keyboardType = UIKeyboardTypeDecimalPad;
        [_squareTextField setValue:[HSPublic colorWithHexString:@"B2B2B2"] forKeyPath:@"_placeholderLabel.textColor"];
        [_squareTextField addTarget:self action:@selector(textFieldAction:) forControlEvents:UIControlEventEditingDidEnd];
        [self.contentView addSubview:_squareTextField];
        [_squareTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView).offset(15);
            make.right.equalTo(weakSelf.contentView).offset(-40);
            make.left.equalTo(weakSelf.nameLabel.mas_right).offset(10);
            make.height.mas_equalTo(20);
        }];
        
        _squareLabel = [[UILabel alloc]init];
        _squareLabel.text = @"m²";
        _squareLabel.font = Font28;
        _squareLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        [self.contentView addSubview:_squareLabel];
        [_squareLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView).offset(10);
            make.right.equalTo(weakSelf.contentView).offset(-10);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        
    }
    return self;
}

- (void)textFieldAction:(UITextField *)textField{
    if ([self.delegate respondsToSelector:@selector(modifSingleTextFieldTableCell:WithEditEndText:)]) {
        [self.delegate modifSingleTextFieldTableCell:self.indexPath WithEditEndText:textField.text];
    }
}


@end


@implementation DecorateAppointInputTextTableCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        _nameLabel.font = Font28;
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:_nameLabel];
        AutoWeakSelf
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(weakSelf.contentView).offset(15);
            make.size.mas_equalTo(CGSizeMake(70, 20));
        }];
        
        _textField = [[UITextField alloc]init];
        _textField.font = Font28;
        _textField.textColor = [HSPublic colorWithHexString:@"333333"];
        [_textField setValue:[HSPublic colorWithHexString:@"B2B2B2"] forKeyPath:@"_placeholderLabel.textColor"];
        [_textField addTarget:self action:@selector(textFieldAction:) forControlEvents:UIControlEventEditingDidEnd];
        [self.contentView addSubview:_textField];
        [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView).offset(15);
            make.right.equalTo(weakSelf.contentView).offset(-10);
            make.left.equalTo(weakSelf.nameLabel.mas_right).offset(10);
            make.height.mas_equalTo(20);
        }];
        
        
    }
    return self;
}

- (void)textFieldAction:(UITextField *)textField{
    if ([self.delegate respondsToSelector:@selector(modifSingleTextFieldTableCell:WithEditEndText:)]) {
        [self.delegate modifSingleTextFieldTableCell:self.indexPath WithEditEndText:textField.text];
    }
}

@end


@implementation DecorateAppointPositionSelectTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        _nameLabel.font = Font28;
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:_nameLabel];
        AutoWeakSelf
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(weakSelf.contentView).offset(15);
            make.size.mas_equalTo(CGSizeMake(70, 20));
        }];
        
        _placeImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"placePicker"]];
        _placeImgView.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:_placeImgView];
        [_placeImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView).offset(15);
            make.left.equalTo(weakSelf.nameLabel.mas_right).offset(10);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        _selectPlaceLabel = [[UILabel alloc]init];
        _selectPlaceLabel.textColor = [HSPublic colorWithHexString:@"B2B2B2"];
        _selectPlaceLabel.font = Font28;
        _selectPlaceLabel.text = @"点击选择地址";
        _selectPlaceLabel.userInteractionEnabled = YES;
        [self.contentView addSubview:_selectPlaceLabel];
        [_selectPlaceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.nameLabel);
            make.left.equalTo(weakSelf.placeImgView.mas_right).offset(10);
            make.right.equalTo(weakSelf.contentView).offset(-40);
            make.bottom.equalTo(weakSelf.contentView).offset(-15);
        }];
        
        _rightImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"rightshap"]];
        _rightImgView.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:_rightImgView];
        [_rightImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.contentView).offset(15);
            make.right.equalTo(weakSelf.contentView).offset(-10);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(selectPlaceLabelAction)];
        [self.selectPlaceLabel addGestureRecognizer:tap];
    }
    return self;
}

- (void)cellForLayout:(NSString *)string{
    if ([string isEqualToString:@"点击选择地址"]||k_Is_Empty(string)) {
        _selectPlaceLabel.textColor = [HSPublic colorWithHexString:@"B2B2B2"];
        _selectPlaceLabel.text = @"点击选择地址";
    }else{
        _selectPlaceLabel.textColor = [HSPublic colorWithHexString:@"333333"];
        _selectPlaceLabel.text = string;
    }
}

- (void)selectPlaceLabelAction{
    if ([self.delegate respondsToSelector:@selector(tapPlaceTableCellEvent)]) {
        [self.delegate tapPlaceTableCellEvent];
    }
}

@end



